package cn.northsea.service.impl;


import cn.northsea.mapper.MenuMapper;
import cn.northsea.pojo.Menu;
import cn.northsea.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> findMenuOneByUid(Integer id) {
        return menuMapper.findMenuOneByUid(id);
    }

    @Override
    public List<Menu> findAll() {
        return menuMapper.findAll();
    }

    @Override
    public List<Menu> findMenuByRid(Integer role_id) {
        return menuMapper.findMenuByRid(role_id);
    }

    @Override
    @Transactional
    public void allocationMenu(Integer role_id, List<Integer> mids) {
        menuMapper.delMenu(role_id);
        menuMapper.allocationMenu(role_id, mids);
    }

    @Override
    public List<Menu> findMenuByUid(Integer userId) {
        return menuMapper.findMenuByUid(userId);
    }

}
